home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-04 / fortran.zip / SBM.LS1 < prev    next >
Text File  |  1991-01-10  |  34KB  |  897 lines

  1.     
  2.     
  3.     
  4.     
  5.     
  6.     
  7.     
  8.     
  9.     
  10.     
  11.     
  12.     
  13.     
  14.     
  15.     
  16.     
  17.     
  18.     
  19.     
  20.     
  21.                              S B M     F O R T R A N
  22.     
  23.                               A FORTRAN answer to 'C'
  24.     
  25.     
  26.     
  27.     
  28.     
  29.                     The best road is designed by the traveller.
  30.     
  31.     
  32.     
  33.     
  34.     
  35.     
  36.                            Copyright (c) 1989-1991 by
  37.     
  38.                                    DUKE DAIGH
  39.     
  40.                           Pine Bluffs, Wyoming 82082-0631
  41.  
  42.     
  43.     
  44.                                    DISCLAIMER
  45.     
  46.     
  47.     
  48.         This is the initial release of SBM FORTRAN.  It is probable that there
  49.         are bugs.  It may NEVER be totally bug-free.  For this reason we make
  50.         the following statement.
  51.    
  52.         This program is supplied as-is.  The author disclaims all warranties,
  53.         expressed or implied. The author assumes no liability for damages which
  54.         might result from the use of this program.
  55.    
  56.         You are encouraged to freely distribute this package.  Mail copies to
  57.         friends.  Put  it up on other boards.  We only request that you
  58.         distribute only unmodified copies.
  59.    
  60.    
  61.         Direct all inquiries, suggestions, etc. to:
  62.    
  63.                             Duke Daigh
  64.                             P.O. Box 631
  65.                             Pine Bluffs, Wyoming  82082-0631
  66.  
  67.     
  68.     
  69.        CONTROL STATEMENTS
  70.               TEST, TEST Numeric. . . . . . . . . . . . . . . . . . . . . 4-1
  71.               Control flags . . . . . . . . . . . . . . . . . . . . . . . 4-1
  72.               Conditional transfers . . . . . . . . . . . . . . . . . . . 4-1
  73.    
  74.               Compare variable to constant, CMP . . . . . . . . . . . . . 4-2
  75.               Compare string to string  . . . . . . . . . . . . . . . . . 4-2
  76.               Unconditional transfers, GOTO, JMP  . . . . . . . . . . . . 4-2
  77.               WAIT  . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-2
  78.               PAUSE . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-2
  79.               STOP, CALL EXIT . . . . . . . . . . . . . . . . . . . . . . 4-2
  80.     
  81.               TABLE_LOOKUP  . . . . . . . . . . . . . . . . . . . . . . . 4-3
  82.     
  83.               IF statements . . . . . . . . . . . . . . . . . . . . . . . 4-4
  84.               Block IF  . . . . . . . . . . . . . . . . . . . . . . . . . 4-5
  85.               Do-loops  . . . . . . . . . . . . . . . . . . . . . . . . . 4-8
  86.     
  87.        RESERVED WORDS AND ARRAYS. . . . . . . . . . . . . . . . . . . . . 5-1
  88.               The command line (command tail) . . . . . . . . . . . . . . 5-1
  89.               Useful program constants  . . . . . . . . . . . . . . . . . 5-1
  90.    
  91.     
  92.        Miscellaneous Intrinsics . . . . . . . . . . . . . . . . . . . . . 6-1
  93.               COPY Array_1 to Array_2 . . . . . . . . . . . . . . . . . . 6-1
  94.               FIND_CHAR 'c', Array  . . . . . . . . . . . . . . . . . . . 6-1
  95.               END  Ignored by the compiler. . . . . . . . . . . . . . . . 6-1
  96.               Masking operations.  AND, XOR, OR . . . . . . . . . . . . . 6-1
  97.               SHIFT Shift a variable. . . . . . . . . . . . . . . . . . . 6-1
  98.               PARSE String, Keword  . . . . . . . . . . . . . . . . . . . 6-1
  99.               PARSE_ONLY String, Keword, 'char' . . . . . . . . . . . . . 6-1
  100.               LDA.  Load address  . . . . . . . . . . . . . . . . . . . . 6-2
  101.               UPCASE.  Convert string to upper case . . . . . . . . . . . 6-2
  102.     
  103.        SYSTEMS STUFF  . . . . . . . . . . . . . . . . . . . . . . . . . . 6-3
  104.               EXCLUDE_RTL . . . . . . . . . . . . . . . . . . . . . . . . 6-3
  105.               LABEL  variable, word/byte. . . . . . . . . . . . . . . . . 6-3
  106.               PRESET data-type,variable . . . . . . . . . . . . . . . . . 6-3
  107.               SETFORM 'c' . . . . . . . . . . . . . . . . . . . . . . . . 6-3
  108.               SETIF 'c' . . . . . . . . . . . . . . . . . . . . . . . . . 6-3
  109.    
  110.    
  111.        Ramdisk  . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-1
  112.    
  113.        Known bugs . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-1
  114.  
  115.     
  116.     
  117.        FEATURES OF SBM FORTRAN
  118.     
  119.        It is a compiler compiler.  It was conceived as a bootstrap system to
  120.        compile parts of itself.  That's why I refer to it as my answer to 'C'.
  121.     
  122.        You can insert assembler coding and macros.  You can invoke the standard
  123.        interrupts.  In other words, you can do anything with this compiler that
  124.        you can do in assembler.  In fact, some of the more complex modules of
  125.        the compiler are WRITTEN IN FORTRAN.  Any future refinements will be
  126.        written in fortran.
  127.     
  128.        The executable module is very compact and efficient compared to other,
  129.        higher-level compilers.
  130.     
  131.        It combines the simplicity of fortran coding with the power of the
  132.        assembler.
  133.     
  134.        You can operate it as you would any other F77 compiler and end up with
  135.        code that will usually run on any other F77 compiler.
  136.     
  137.        You can place more than one statement on each record.
  138.     
  139.        You can append comments to each statement.
  140.     
  141.        The compiled module uses buffered input, making it very fast. 
  142.        Pathnames are used so that  you can access data on other drives and
  143.        in other directories.
  144.     
  145.        All console/keyboard i/o can be re-directed.
  146.     
  147.        It has many powerful intrinsic operations, such as:  PARSE, COPY,
  148.        TABLE-LOOKUP, COMPARE, etc..
  149.     
  150.        You can do masking operations, such as AND, OR, XOR.
  151.     
  152.        You can shift variables left or right, by the number of bits that you
  153.        specify.
  154.     
  155.    
  156.    
  157.    
  158.    
  159.    
  160.    
  161.    
  162.    
  163.    
  164.    
  165.    
  166.    
  167.    
  168.    
  169.    
  170.    
  171.                                      iv
  172.  
  173.                                                                             1-1
  174.     
  175.        FORTRAN STATEMENTS
  176.     
  177.        There are two types of statements, executable and non-executable.
  178.     
  179.        Non-executable statements are used to describe the characteristics and
  180.        format of data.
  181.     
  182.        Executable statements specify actions that the program is to take
  183.        against, or for the welfare of the data, such as READ, WRITE, etc..
  184.     
  185.        Each source input line can be as long as 80 characters.  Statement
  186.        Continuations are permitted only on certain statements.  they are:
  187.                OPEN, FORMAT, data initialization.
  188.     
  189.        You can use statement labels to identify and reference individual
  190.        statements in a program.  You can label any statement but only labled
  191.        statements can be referenced.
  192.     
  193.     
  194.        SYMBOLIC NAMES AND KEYWORDS
  195.     
  196.        Symbolic names, chosen by the programmer, identify program variables and
  197.        statement lables.  A keyword is a pre-assigned identifier that you use to
  198.        specify a particular action that the program is to take. Keywords are
  199.        also known as RESERVED WORDs (see 5-1).
  200.     
  201.        A symbolic name is a sequence of one to 31 alphanumeric characters.
  202.     
  203.        When used to identify program variables, the first character must not be
  204.        numeric.  The name may consist of just about any printable character
  205.        except for + - * / ( ) ; | apostrophy or comma.  You cannot use reserved
  206.        words to identify program variables.
  207.     
  208.        Standard fortran labels consist of numeric lables only.  SBM fortran
  209.        allows either, except for lables of format statements, which must begin
  210.        with a numeric digit 0-9. Lables cannot begin with + - * ; |. Lables
  211.        cannot use ( ) [ ] apostrophy or comma.  Reserved words may be used as
  212.        lables.
  213.     
  214.        Statement lables must begin in column 1.  All other statements must begin
  215.        in  any column other than 1. By all means use column 7 if you wish to
  216.        adhere to an accepted standard.
  217.     
  218.        You can assign more than one lable to a statement if you wish.  In doing
  219.        so, you can refer to it by either label.
  220.     
  221.     
  222.        More than one statement may appear on each source input record by
  223.        terminating each (except the last) with the marker code '|'. (on most
  224.        keyboards this is uppercase backslash)  The format of the additional
  225.        statements is no different than the first, so don't forget to follow the
  226.        marker with at least one blank, unless it is to be a label.
  227.     
  228.     
  229.     
  230.        STATEMENT ORDER
  231.     
  232.        Doesn't matter. mix or match. the compiler will sort them out.
  233.  
  234.                                                                             1-3
  235.     
  236.        DATA TYPES
  237.     
  238.    *   SBM provides three data types: BYTE,  WORD and Doublewords.
  239.     
  240.        BYTE data occupies 8 bits (one byte) of memory and is normally only used
  241.        for ascii characters and strings, or logical variables, such as
  242.        programmer-specified switches and flags. You can use this data type for
  243.        numerical values, up to 255.
  244.     
  245.        WORD data are numbers that are whole positive, negative or zero-value
  246.        numbers. WORD data values occupy 16 bits (two bytes) of memory and can
  247.        contain numbers from -32,768 to 32,767. Although a word can hold a number
  248.        as large as 65,635, this implementation provides no standard way to
  249.        output the larger numbers.
  250.     
  251.    *   DOUBLEWORDs are 32-bit (integer*4) integers. The may contain numbers
  252.        within the range -2,147,483,648 to +2,147,483,647. Integer*4 data is very
  253.        useful for accounting applications where larger numbers are involved and
  254.        precision is required in transactions. For example, monitary amounts can
  255.        be set into integer*4 variables using total cents, rather than dollars
  256.        and cents. When the results are to be printed, a special feature of
  257.        integer*4 values allows you to insert decimal points where applicable.
  258.     
  259.     
  260.        In SBM FORTRAN, the following mean the same:
  261.     
  262.        CHARACTER, BYTE, INTEGER*1, LOGICAL       8-bit data.
  263.     
  264.        INTEGER, WORD, INTEGER*2                 16-bit data.
  265.     
  266.     
  267.        CHARACTER strings appear in memory as a collection of ASCII characters
  268.        terminated by a binary zero.  This zero terminator controls all
  269.        operations in which this data type is manipulated, such as compares,
  270.        copys, input-output, etc.. With the terminator, this is known as as
  271.        an ASCIIZ string.
  272.     
  273.     
  274.     
  275.     
  276.     *  Integer*4 is not totally implemented.  Some parts of it are. Some not.
  277.        I wouldn't recommend that you try it yet. It will be implemented in the
  278.        next update.
  279.  
  280.                                                                             1-5
  281.     
  282.        DATA DECLARATION and INITIALIZATION
  283.     
  284.     
  285.        There are two modes in which you can declare variables, (1) declare and
  286.        (2) declare/initialize.
  287.     
  288.          (1) Declare.  The 'standard' declaration in which you specify the size
  289.          of individual elements and optionally set aside a specific amount of
  290.          memory to contain these elements in an array.
  291.     
  292.              Example:  INTEGER ELEV(20), DIST(20), SLOPE, DELTA(3)
  293.     
  294.        (2) Declare/initialize. This mode allows you to declare a variable or an
  295.        array and establish it's initial value(s). When initializing arrays, only
  296.        as much memory as needed to contain the given data will be allocated.
  297.        This statement can be continued. When used, this option must be the last
  298.        (or only) declaration on the source statement. You can, of course, put
  299.        multiple statements on one physical record. Examples:
  300.     
  301.            integer day/5/|   integer month/12/|   integer year/1948/
  302.     
  303.            integer*1 level(4), mace/3/
  304.     
  305.            character pathname/'c:sales.jan',0/
  306.     
  307.     
  308.          This statement is tricky.  If you forget the closing '/', the compiler
  309.          will search the rest of your source looking for one.
  310.     
  311.          Here's another example, taken right out of the compiler itself:
  312.     
  313.            character registers/
  314.              'AX',0,'BX',0,'CX',0,'DX',0,'SI',0,'DI',0,'BP',0
  315.              'AL',0,'BL',0,'CL',0,'DL',0,'AH',0,'BH',0,'CH',0
  316.              'DH',0,'[SI]',0,'[DI]',0,'[BX]',0,'[BP]',0,'$'/
  317.     
  318.        If you want to declare an array of a certain size but initialize only the
  319.        first portion, here's another example from the compiler:
  320.     
  321.            character outbuf(80)
  322.            data outbuf/'e:sbm.t$$',0/
  323.     
  324.     
  325.     
  326.        THE DATA STATEMENT
  327.     
  328.        This is an executable statement!  Most fortran reference manuals don't
  329.        admit it but it is.  Because of this fact, it can be used anywhere in
  330.        the program.  As you see above, you can initialize a variable or an
  331.        array with it.  You can also change data values on the fly. Over and
  332.        over.
  333.     
  334.        Here's a handy use of this feature:
  335.     
  336.           If(code.eq.4) DATA table/1,2,3,4,5/
  337.           If(code.eq.5) DATA table/6,7,8,9,0/
  338.  
  339.                                                                             2-1
  340.     
  341.        OPEN statement
  342.     
  343.        The OPEN statement establishes the connection between a fortran UNIT and
  344.        a file or device. You must issue this statement before any diskfile I/O
  345.        can be used. Note: you cannot close a file and re-open.
  346.     
  347.        syntax:
  348.     
  349.        OPEN(UNIT,ALIAS=buff-name,FILE='filespec',status='old/new/append',
  350.                                                                      RECL=nnn)
  351.     
  352.        where:
  353.     
  354.        UNIT is a numeric constant, in the range of 5-255.
  355.     
  356.        The unit number is converted to a control block name by appending the
  357.        number to 'IOCB_'. The unformatted input record can be referenced by this
  358.        name (as well as any alias that you may specify). Unit 10, for example
  359.        may be referenced by the name 'IOCB_10'. An example of this can be found
  360.        under UNFORMATTED READ.
  361.     
  362.        ALIAS is an alternate name by which the file can be addressed when
  363.        reading unformatted (raw) data. Raw mode, when used instead of formatted
  364.        or list-directed input results in much faster i\o. Unformatted i/o is
  365.        discussed more fully in READ statements. This parameter is optional.
  366.     
  367.     
  368.        FILE='filespec'. Pathnames can be used here. You may name a file that is
  369.        to be used, or specify a character array which contains an ASCIIZ
  370.        filespec. If the name itself is used here, it must be enclosed in quotes.
  371.        If an array containing the filespec is used, it must not be quoted.
  372.     
  373.     
  374.        STATUS='old/new/append'. If the file is to be created, use 'new'. If the
  375.        file is to be read/write, use 'old'. If you have an existing file that is
  376.        to be enlarged, use 'append'. If you use 'new', any existing file by that
  377.        name will be replaced. If you omit this parameter, 'old' is assumed. The
  378.        quotes are optional, for compatability.
  379.     
  380.     
  381.        RECL=nnn. SBM uses a buffered input system, resulting in very high-speed
  382.        input.  The buffering system uses two arrays.  one for the input buffer,
  383.        (into which is loaded blocks of non-predictable pieces) and the record
  384.        buffer which will contain only the individual record.  It is from the
  385.        record area that formatting takes place.  You can use the RECL option to
  386.        insure that no record exceeds a given size.  If this option is omitted,
  387.        record length defaults to 80.
  388.  
  389.                                                                             2-3
  390.     
  391.        UNFORMATTED READ
  392.     
  393.     
  394.        Syntax:   READ(UNIT) list
  395.     
  396.        This is the most simple of the input statements.  It transfers one
  397.        record of binary data to the array 'list'.  No conversion takes place.
  398.        (A typical file of data information is stored as ASCII characters. No
  399.        conversion is required if all you want to do is to examine it.  It is
  400.        considered to be binary data)
  401.     
  402.     
  403.        If 'list' is omitted, one record is by-passed.  For that reason it is
  404.        sometimes referred to as a 'null' read, or 'by-pass' read.
  405.     
  406.        The contents of the record are available in the IOCB or under the ALIAS
  407.        that was specified in the 'open'.
  408.     
  409.        Here's an example of how you might use it to read and display a file.
  410.     
  411.     
  412.                 open(5,file='reform.for')
  413.            1000 read(5)
  414.                 if(eof) stop
  415.                 write(*) iocb_5
  416.                 goto 1000
  417.                 end
  418.     
  419.        Type this one in and try it. It will make your hair stand on end! If you
  420.        were to try this example on a large file, you can see that it wouldn't do
  421.        you much good. The output would fly by so fast that you couldn't read
  422.        most of it.
  423.  
  424.                                                                             2-5
  425.     
  426.        WRITE STATEMENTS
  427.     
  428.        WRITE statements transfer data from memory to a specified I/O unit. You
  429.        can reference both external and internal files.
  430.     
  431.        Syntax:   WRITE(UNIT [,FMAT]) list
  432.     
  433.     
  434.     
  435.     
  436.     
  437.        UNFORMATTED WRITE
  438.     
  439.     
  440.        Syntax:   WRITE(UNIT) list
  441.     
  442.        This statement transfers one record of ascii data to UNIT. The data must
  443.        be terminated by a binary zero. No formatting takes place.
  444.     
  445.        If 'list' is present, it must be the name of an array.  If omitted, the
  446.        formatted contents of the IOCB is written.
  447.     
  448.        This is the form of output that you should use to insert control
  449.        characters, such as escape-sequences, extra line feeds, backspaces, etc.
  450.     
  451.        Example, from 'testall.for'
  452.     
  453.                 data outbuf/esc,'[2J',0/
  454.                 write(*) outbuf  ; clear the screen
  455.     
  456.     
  457.     
  458.     
  459.     
  460.        FORMATTED WRITE
  461.     
  462.        Syntax:   WRITE(UNIT,FMAT]) list
  463.     
  464.        This is a two-step operation and is the revese of formatted read.
  465.     
  466.        Step 1 formats the specified data fields from binary to decimal as
  467.        required and copies ascii data or quoted strings into the IOCB.
  468.     
  469.        Step 2 writes the contents of the IOCB to the specified UNIT.
  470.     
  471.  
  472.                                                                             2-7
  473.     
  474.        FORMAT STATEMENTS
  475.     
  476.        Format is a labled non-executable statement that specifies the format of
  477.        data being transferred between memory and i/o devices. It may appear
  478.        anywhere in the program. The first character of the label must be
  479.        numeric. The method by which formatting takes place is by the use of
  480.        field and edit descriptors with which the type and size of the various
  481.        data fields is specified and quoted strings for constant ascii data.
  482.     
  483.        Each field descriptor consists of letter which identifies the type of
  484.        data, followed by a number indicating the width of the data field. In
  485.        some cases the width is optional.
  486.     
  487.        Format control proceeds from left to right, matching each field
  488.        descriptor with each item in the i/o list.
  489.     
  490.        SBM uses 3 field descriptors, A, I, X
  491.     
  492.        Character data.
  493.        The 'A' field descriptor transfers character data.  It has the form
  494.     
  495.            A[w]
  496.     
  497.        If W is present the field width is w-characters. If omitted, the field
  498.        width is the size of the data item in the i/o list. The name in the list
  499.        can be any data type, character, logical or integer. On input, any
  500.        existing data is simply overlayed.
  501.     
  502.     
  503.        Integer data   I[w]
  504.     
  505.        If the output binary number, when converted to decimal, exceeds the
  506.        allocated space, the number will back-flow into the previous field,
  507.        replacing whatever the formatter just put there. (not like standard
  508.        fortran, which would fill the output field with asterisks. If enough of
  509.        you complain, I will comply with the standard).
  510.     
  511.     
  512.        Skip    [w]x
  513.     
  514.        Quoted strings.
  515.     
  516.     
  517.        Dollar sign descriptor  $
  518.     
  519.        Normally, all output records are terminated by a carriage return. The
  520.        dollar sign descriptor inhibits this action. The option is intended for
  521.        interactive I/O and is valid only for output statements. It permits user
  522.        response to appear on the same line as a prompt.
  523.     
  524.        example:   WRITE(*,*) 'Enter project number: ',$
  525.                   READ(*,*) PROJ
  526.     
  527.        When used, the dollar sign descriptor must the the last item of the
  528.        output statement.
  529.  
  530.                                                                             3-1
  531.     
  532.        ARITHMETIC EXPRESSIONS
  533.     
  534.        SBM fortran does not yet support more than a simple one-function
  535.        expression.  The simpler form of an expression, while requiring more
  536.        statements to complete some calculations, still maintains compatability
  537.        with higher-level compilers.
  538.     
  539.        Thus, we are limited to such statements as:
  540.     
  541.                 counter=counter+1
  542.                 range=limit-base
  543.                 etc..
  544.     
  545.        String expressions allow a little more versatility, such as:
  546.     
  547.                 filespec='c:modemuf.asm'
  548.                 letter='A'
  549.                 etc..
  550.     
  551.     
  552.        In addition to the above arithmetic statements, SBM fortran also supports
  553.        the following statements:
  554.     
  555.        INC, DEC      Add or subtract 1 from an integer variable.  This is the
  556.                      most efficient way to add or subtract the constant 1 from
  557.                      a variable.
  558.     
  559.                      example:    inc counter    ; add one to 'counter'
  560.                                  dec tally      ; subtract one from 'tally'
  561.     
  562.     
  563.     
  564.        ADD, SUB      Add or subtract constant or value from register from an
  565.                      integer variable.  This is much faster than standard
  566.                      fortran and uses less code.
  567.     
  568.                      example:    add index,10        ; add 10 to index.
  569.     
  570.                                  index=index+10      ; the usual, less
  571.                                                      ; efficient way.
  572.     
  573.     
  574.     
  575.  
  576.                                                                             4-1
  577.     
  578.                                CONTROL STATEMEMTS
  579.     
  580.        There's no point in writing a program if you can't control what it does.
  581.        Without flow control, a program would sequentially execute each of your
  582.        statements and then blow up. That would be tacky.
  583.     
  584.        Fortran flow control statements provide a means of modifying the normal
  585.        sequemntial flow of execution.
  586.     
  587.        Flow control statements are: TEST, COMPARE, CMP, DO, CONTINUE, GOTO,
  588.        JMP, STOP and CALL EXIT. Some of these are not standard but all are
  589.        handy.
  590.     
  591.     
  592.     
  593.        TEST
  594.     
  595.        Usage:  TEST VARIABLE, MASK
  596.            or  TEST VARIABLE, NUMERIC
  597.     
  598.        You can test a variable using a mask, or TEST NUMERIC.
  599.        
  600.        When a TEST is performed, control flags are set, depending upon
  601.        the results of the test. You must then use an if-statement or
  602.        conditional jump. Control flags are: equal, not equal, zero,
  603.        not zero, carry and not carry.
  604.     
  605.            (EQ), (NE), (ZR), (NZ), (CY), (NC),  (NUMERIC), (NOT.NUMERIC)
  606.     
  607.        CONDITIONAL JUMPs are JNC, JC, JZ, JNZ
  608.     
  609.        Using a MASK, you can see if a particular bit or any one of a group
  610.        if bits is set.  It does this with a logical AND, and sets flags but
  611.        changes nothing in memory.
  612.     
  613.          Example:  see if an integer is odd or even.
  614.                            test(answer,1)
  615.                            if(zr) goto even
  616.                       (or) jz even
  617.     
  618.     
  619.        To test an individual ascii character to determine whether it is
  620.        numeric or not, use the following syntax:
  621.     
  622.        TEST VARIABLE, NUMERIC
  623.     
  624.        This checks an ascii character to see if it is within the range of
  625.        '0' - '9'.  As a result of this test, the logical variable 'numeric'
  626.        is set to either true or false.
  627.     
  628.                Example:  test(inbuf(1),numeric)
  629.                          if(not.numeric) goto alpha
  630.  
  631.                                                                             4-3
  632.     
  633.        TABLE_LOOKUP
  634.     
  635.        Given a character string, tests to see if the string exists in a
  636.        specified table. Each entry in the table must be enclosed within quotes
  637.        and must be in upper case. each entry must be followed by binary zero.
  638.        The table must be terminated by a '$'.
  639.     
  640.        If the given string is found to be present in the table, register CX
  641.        indicates it's relative position in the array. i.e., in the table
  642.        below, AX=1, BX=2, CX=3, etc.
  643.     
  644.        If the string cannot be found, CX=0 and carry-flag is set.
  645.     
  646.        Here's a sample table.
  647.     
  648.         character registers/
  649.           'AX',0,'BX',0,'CX',0,'DX',0,'SI',0,'DI',0,'BP',0
  650.           'AL',0,'BL',0,'CL',0,'DL',0,'AH',0,'BH',0,'CH',0
  651.           'DH',0,'[SI]',0,'[DI]',0,'[BX]',0,'[BP]',0,'$'/
  652.     
  653.        The following example wants to see if the character string that is in
  654.        the array 'keword' is any of the entries in the table 'registers'.
  655.     
  656.        -   see if a destination is register.
  657.            table_lookup keword,registers
  658.            if(nc) goto destin_ok
  659.     
  660.     
  661.     
  662.     
  663.        TABLE_ADD
  664.     
  665.        Following a table-lookup operation, adds a string to a given table.
  666.        While this is not a control statement, it is included here because it
  667.        is frequently used immediately following a non-successful table_lookup.
  668.     
  669.        Example:  install the string in the array 'keword' in the table.
  670.     
  671.        -   new symbol, put it in table.
  672.            table_add keword
  673.     
  674.  
  675.                                                                             4-5
  676.     
  677.        There are two types of  IF statements:
  678.     
  679.           o  The single IF
  680.     
  681.           o  The block IF
  682.     
  683.           (The arithmetic IF is not supported by SBM fortran)
  684.     
  685.        The single IF statement conditionally executes a single statement. It
  686.        has the form
  687.     
  688.          IF (exp) stmt
  689.     
  690.        where:
  691.          exp is a logical expression.
  692.     
  693.          stmt is a single, not continued, fortran statement.
  694.  
  695.                                                                             4-7
  696.     
  697.     
  698.        There are two types of data which can be compared in an IF statement,
  699.        numeric or literal. Literals are recognized by the presence of quotes.
  700.        Here are some examples:
  701.     
  702.     
  703.        * Author used the following program to test out and debug IF statements.
  704.        integer ibuf
  705.        write(*,*) 'enter a number: ',$
  706.        read(*,*) ibuf
  707.        if(ibuf.eq.100) then
  708.        write(*,*) '---------------'
  709.        write(*,*) 'number is equal'
  710.        else
  711.        write(*,*) 'number is NOT equal'
  712.        endif
  713.        if(ibuf.lt.100) write(*,*) 'number is LT 100'
  714.        if(ibuf.le.100) write(*,*) 'number is also LE  100'
  715.        if(ibuf.gt.100) write(*,*) 'number is GT 100'
  716.        if(ibuf.ge.100) write(*,*) 'number is also GE 100'
  717.        stop
  718.     
  719.           - - - - - - - - - - - - - - - - - - - - - - - -
  720.     
  721.        ; this program reformats a WASM LST file to straight ASM format. You
  722.        ; might want to do this to have a source that has the macros expanded.
  723.     
  724.               open(5,file=infile,status='old',recl=132,alias=inbuf)
  725.        loupe  read(inbuf)
  726.               if(eof) stop
  727.               if(inbuf.eq.20h)    goto loupe
  728.               if(inbuf.eq.'L')    goto loupe
  729.               if(inbuf+22.eq.20h) goto loupe
  730.               write(1) inbuf+26
  731.               jmp loupe
  732.     
  733.  
  734.                                                                             5-1
  735.     
  736.        RESERVED KEYWORDS and ARRAYS
  737.     
  738.        FORTRAN has many keywords that are meaningful to the compiler, such as
  739.        IF, READ, WRITE, etc..  In addition to the standard list of reserved
  740.        keywords, SBM fortran includes some options not provided in other
  741.        systems:
  742.     
  743.     
  744.        LDA, EXCLUDE, WAIT, JMP, JNC, JC, JZ, JNZ, AND, XOR, OR, SHIFT,
  745.        SETFORM, SETIF, SHOW_CHAR, INCLUDE, UPCASE, INC, DEC, TEST,
  746.        ADD, SUB, CMP, LABEL, PARSE, COPY, NEXCHAR, TABLE_LOOKUP, TABLE_ADD,
  747.        COMPARE, FIND_CHAR, CRLF, PRESET.
  748.     
  749.        YOU CANNOT USE RESERVED WORDS AS VARIABLE NAMES, although any of them
  750.        may be used as statement lables.
  751.     
  752.     
  753.        In addition to the above reserved words, we also have the following
  754.        arrays, which are  considered as reserved words:
  755.     
  756.        COMMAND, CONSOLE, INFILE, WORKBUF, OUTFILE, WORKBUF2.
  757.     
  758.     
  759.     
  760.        THE COMMAND LINE
  761.     
  762.        One of the problems facing the high-level programmer is how to access the
  763.        data that we entered at the system prompt. SBM fortran sets this data
  764.        where it can be easily used. The command tail can be located in the
  765.        character array COMMAND. From there it can be parsed or otherwise used
  766.        just like any other character array. In addition, the first two tokens
  767.        are parse into INFILE (alias WORKBUF) and OUTFILE (alias WORKBUF2) and
  768.        may be used as filenames in the OPEN statement.
  769.     
  770.        The advanced programmer will find these options to be of significant
  771.        value.
  772.     
  773.     
  774.        PROGRAM CONSTANTS
  775.     
  776.     
  777.        Rather than using numerical equivalents for commonly needed constants,
  778.        you may choose from the following list of pre-assigned symbolic names.
  779.     
  780.           CR        Carriage return.  Use instead of 0Dh, 13 decimal.
  781.           LF        Line feed. Use instead of 0Ah, 10 decimal.
  782.           ESC       Escape.  For ansi screen control, 1Bh, 27 decimal.
  783.           FF        Form feed.  To eject the page in printer files.
  784.           TAB
  785.           BS        Back space.
  786.           COMMA     Equivalent to 2Ch.
  787.           QUOTE     Equivalent to 27h.
  788.           QUOTES    Equivalent to 22h.
  789.           False     Equivalent to binary zero.
  790.           True      Equivalent to binary 1.
  791.  
  792.                                                                             6-1
  793.        MISCELLANEOUS INTRINSIC FUNCTIONS
  794.     
  795.    
  796.    
  797.        COPY Array_1, Array_2
  798.     
  799.        Copies a character string to another array. Can be indexed.
  800.     
  801.    
  802.    
  803.     
  804.        FIND_CHAR  'c', Array
  805.     
  806.        Searches a character string until the specified character is located.
  807.     
  808.    
  809.        END    Optional for compatability. Ignored by the compiler.
  810.     
  811.     
  812.    
  813.        AND, XOR, OR  Masking operations
  814.    
  815.        Usage:  AND variable,mask.  Mask is hex constant, register, memory.
  816.    
  817.    
  818.    
  819.     
  820.        SHIFT         Shift a variable, left or right.
  821.     
  822.        Usage:  SHIFT VARIABLE [,nbits]
  823.     
  824.        Shifts the variable the number of bits specified. If nbits absent, shift
  825.        the variable one bit right. Otherwise you must specify the number of
  826.        shifts. If nbits is preceded by a minus sign, shift is to the left.
  827.     
  828.                     Example:  shift 'number' one bit right.
  829.                               SHIFT NUMBER
  830.     
  831.                     nother:   shift 'number' 3 bits left.
  832.                               SHIFT NUMBER,-3
  833.     
  834.        If you  wish to shift only one bit left, it can be more efficiently
  835.        done by adding the number to itself.  It accomplishes the same result.
  836.     
  837.                     Example:  ibuf=ibuf+ibuf
  838.     
  839.                     or better yet:   ax=ibuf
  840.                                      add ibuf,ax
  841.  
  842.                                                                             6-3
  843.        SYSTEMS STUFF
  844.    
  845.        Things on this page are of no value to users.  They are included here
  846.        only for Author's convenience.
  847.    
  848.    
  849.        LABEL  variable, word/byte. Allows alias in system modules.  Must be
  850.               issued immediately before the data decalaration statement.
  851.    
  852.        PRESET data-type,variable   Establish name and type in symbol
  853.                       table for external variable.  data type is byte/word.
  854.    
  855.        SETFORM 'c'    Change default character in format name. Normally
  856.                       fmt_nnn.  Changes the 't'.  Sample: fma_001.
  857.    
  858.        SETIF 'c'      Change default character in if-labels. Normally
  859.                       true_000.  Changes first '0'.  Sample: true_a01.
  860.    
  861.        Example of the above two.       SETFORM a|   SETIF a
  862.  
  863.                                                                             7-1
  864.     
  865.        Greater speed can be realized by using a ramdisk.  To take advantage
  866.        of this feature, include in your autoexec.bat file the following:
  867.     
  868.           SET RAMDISK=d
  869.     
  870.        Where 'd' is your ramdisk drive.  i.e. SET RAMDISK=E
  871.     
  872.     
  873.     
  874.        In the batch files, notice the commands SET BATCH=TRUE and
  875.        SET BATCH=.
  876.     
  877.        These two commands are used by the compiler to determine the course
  878.        or action when the requested source file cannot be found.  They are of
  879.        no concern for normal operations and should not be disturbed.
  880.    
  881.  
  882.                                                                              8-1
  883.        KNOWN BUGS
  884.    
  885.        I am aware of the following bugs.  If I take time to correct them
  886.        now, I may not get this system on the boards before I move to Wyoming.
  887.        They will be addressed in the next update.
  888.    
  889.    
  890.        1.  If you re-define a variable, you get no error message but all
  891.        sorts of seemingly unrelated problems.
  892.    
  893.    
  894.        2. if(inbuf.eq.';')                                SBM.ASM(get_record)
  895.        Input takes the ';' as begin comment, thereby truncating the statement.
  896.    
  897.